#include "CPEGaussEliminationMethod.h"
#include <fstream>
int main(int argc, char* argv[])
{
	std::ofstream my_out("LMM_Info.txt");
	my_out << "ABM" << std::endl;
	for(int p = 0; p != 5; p++) {
		my_out << "Bs";
		if(p != 0) {
			my_out << "-" << p;
		}
		my_out << "\t\t";
	}
	my_out << std::endl;
	int m;
	for(int p = 1; p != 5; p++) {
		my_out << "p=" << p << std::endl;
		RationalNum A[(p + 1)*(p + 1)];
		RationalNum b[p + 1];
		for(int k = 0; k != p + 1; k++) {
			if(k == 0) {
				A[p].set(1, 1);
			}
			int j1 = 1;
			int j2 = 1;
			for(int j = 0; j != k; j++) {
				j1 = j1*(p - 1);
				j2 = j2*p;
			}
			b[k].set(j1 - j2, 1);
			for(int j = 0; j != p + 1; j++) {
				if(k != 0) {
					m = 1;
					for(int l = 0; l != k - 1; l++) {
						m = m*j;
					}
					A[k*(p + 1) + j].set(-k*m, 1);
				}
			}
		}
		CPEGaussEliminationMethod(A, b, p + 1);
		for(int j = p; j != -1; j--) {
			my_out << b[j] << "\t\t";
		}
		my_out << std::endl;
	}

	my_out << std::endl;
	my_out << "AMM" << std::endl;
	for(int p = 0; p != 5; p++) {
		my_out << "Bs";
		if(p != 0) {
			my_out << "-" << p;
		}
		my_out << "\t\t";
	}
	my_out << std::endl;
	for(int p = 1; p != 6; p++) {
		my_out << "p=" << p << std::endl;
		RationalNum A[p*p];
		RationalNum b[p];
		if(p == 1) {
			A[0].set(1,1);
			b[0].set(1,1);
		}
		for(int k = 1; k != p + 1; k++) {
			int j1 = 1;
			int j2 = 1;
			for(int j = 0; j != k; j++) {
				j1 = j1*(p - 2);
				j2 = j2*(p - 1);
			}
			b[k - 1].set(j1 - j2, 1);
			for(int j = 0; j != p; j++) {
				if(k != 0) {
					m = 1;
					for(int l = 0; l != k - 1; l++) {
						m = m*j;
					}
					A[(k - 1)*p + j].set(-k*m, 1);
				}
			}
		}
		CPEGaussEliminationMethod(A, b, p);
		for(int j = p - 1; j != -1; j--) {
			my_out << b[j] << "\t\t";
		}
		my_out << std::endl;
	}
	my_out << std::endl;

	my_out << "BDF" << std::endl;
	my_out << "Bs" << "\t\t";
	for(int s = 0; s != 4; s++) {
		my_out << "Xs";
		if(s != 0) {
			my_out << "-" << s;
		}
		my_out << "\t\t";
	}
	my_out << std::endl;
	for(int p = 1; p != 5; p++) {
		my_out << "p=" << p << std::endl;
		RationalNum A[(p + 1)*(p + 1)];
		RationalNum b[p + 1];
		for(int j = 0; j != p; j++) {
			m = 1;
			for(int k = 0; k != p + 1; k++) {
				A[k*(p + 1) + j].set(m,1);
				m = m*j;
			}
		}
		m = 1;
		for(int k = 0; k != p + 1; k++) {
			b[k].set(-m, 1);
			A[k*(p + 1) + p].set((0-k)*m/p, 1);
			m = m*p;
		}
		CPEGaussEliminationMethod(A, b, p + 1);
		my_out << b[p] << "\t\t";
		my_out << "1" << "\t\t";
		for(int j = p - 1; j != -1; j--) {
			my_out << b[j] << "\t\t";
		}
		my_out << std::endl;
	}
	my_out.close();
}
